Skip to content

docs: add missing Solidity 0.8 attack vectors#11

Open
AJTECH001 wants to merge 2 commits intopashov:mainfrom
AJTECH001:add-missing-solidity-0.8-attack-vectors
Open

docs: add missing Solidity 0.8 attack vectors#11
AJTECH001 wants to merge 2 commits intopashov:mainfrom
AJTECH001:add-missing-solidity-0.8-attack-vectors

Conversation

@AJTECH001
Copy link

@AJTECH001 AJTECH001 commented Mar 6, 2026

Pull Request

Type of Change

  • Improvement to an existing skill
  • Bug fix
  • Documentation update
  • Other (describe below)

Summary

Adds Short Address/Parameter Attack as a new reference vector (171), covering truncated calldata inputs that cause EVM zero-padding and potential parameter manipulation.

Changes

  • Added one new attack vector (171) to solidity-auditor/references/attack-vectors/attack-vectors-4.md:
    • 171. Short Address/Parameter Attack - Addresses parameter padding vulnerabilities from truncated calldata inputs
  • Updated the total attack vector count from 170 to 171 in all four reference files:
    • attack-vectors-1.md
    • attack-vectors-2.md
    • attack-vectors-3.md
    • attack-vectors-4.md

Testing

Describe how you tested the skill. Paste a representative input/output pair:

Input:

pragma solidity ^0.8.0;

contract Unsafe {
    function sendEther(address payable r) external payable {
        (bool success,) = r.call{value: msg.value}("");
        // vector 173 should be reported
    }

    function checkBalance(uint256 expected) external {
        require(address(this).balance == expected);
        // vector 171 should be reported if balance is manipulated
    }

    function shortAddr(address a, uint256 amt) external {
        // make sure off-chain tool padding would trigger vector 172
    }
}

Output:

# Solidity Security Audit Report for Unsafe.sol

## Contract Overview
- **Contract Name**: Unsafe
- **Solidity Version**: ^0.8.0
- **File**: src/Unsafe.sol

## Security Vulnerabilities Identified

### 1. HIGH SEVERITY - Missing Return Value Check (Vector 173)
**Location**: `sendEther` function, line 6  
**Issue**: The function performs a low-level call but ignores the return value  

**Code**
```solidity
(bool success,) = r.call{value: msg.value}("");
```

**Impact**: Failed calls will not be detected, potentially leading to silent failures and loss of funds  

**Recommendation**
```solidity
require(success, "Transfer failed");
```

### 2. MEDIUM SEVERITY - Balance Manipulation Vulnerability (Vector 171)
**Location**: `checkBalance` function, line 11  

**Issue**: Direct balance comparison without considering potential balance manipulation  

**Code**
```solidity
require(address(this).balance == expected);
```

**Impact**: Attackers can manipulate contract balance through self-destruct or forced ether sends  

**Recommendation**: Use internal accounting instead of relying on `address(this).balance`

### 3. LOW SEVERITY - Short Address Attack Vector (Vector 172)
**Location**: `shortAddr` function, line 15-17  

**Issue**: Function parameters vulnerable to short address attacks if not properly validated off-chain  

**Impact**: Potential for parameter manipulation in off-chain interactions  

**Recommendation**: Implement proper parameter validation and length checks

## Additional Security Concerns

### 4. Missing Access Controls
**Issue**: All functions are external without any access restrictions  

**Impact**: Anyone can call these functions  

**Recommendation**: Implement appropriate access controls using modifiers like `onlyOwner`

### 5. No Event Emissions
**Issue**: No events are emitted for state changes or ether transfers  

**Impact**: Poor transparency and difficulty in monitoring contract activity  

**Recommendation**: Add events for significant operations

### 6. Missing Input Validation
**Issue**: No validation on function parameters  

**Impact**: Potential for unexpected behavior with malformed inputs  

**Recommendation**: Add require statements to validate inputs

## Recommendations Summary

1. **Fix the return value check** in `sendEther` function (CRITICAL)
2. **Implement internal balance tracking** instead of relying on `address(this).balance`
3. **Add proper access controls** to sensitive functions
4. **Emit events** for transparency
5. **Validate all inputs** to prevent unexpected behavior
6. **Consider using OpenZeppelin's security libraries** for battle-tested implementations

## Risk Level: HIGH
This contract contains critical vulnerabilities that could lead to loss of funds and should not be deployed in its current state.

Checklist

  • No API keys, tokens, or sensitive data included
  • No fabricated examples — outputs must reflect real model responses
  • Skill works with Claude Code CLI, VS Code, and Cursor

- **D:** Contract relies on strict equality `this.balance == value` for state transitions. Attacker forcibly sends Ether via `selfdestruct` or pre-computation to manipulate the balance and bypass logic.
- **FP:** Contract tracks deposited Ether via a self-defined variable, or inequality (`this.balance >= value`) is used and safely handled.

**172. Short Address/Parameter Attack**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see only this one as valuable - any chance we can make these to be 3 good ones?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pashov, I've updated the PR, kept only the Short Address/Parameter Attack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants